<template>
	<view class="Clist">
		<view class="list">
			<view class="item" v-if="info.length != 0">
				<view class="address">
					<image src="/static/index/address.png" mode=""></image>
					<view class="info">
						<view class="usermsg">
							<text class="name">{{info.name}}</text>
							<text class="phone">{{info.phone}}</text>
						</view>
						<view class="addressmsg">
							<text>{{info.area_name}} {{info.address}}</text>
						</view>
					</view>
				</view>
				<view class="top" v-for="(item,index) in info.goods" :key='index'
					@click="toPage('/pages/goodsdetail/index?id='+item.id)">
					<image :src="getimg(item.logo_url)" mode=""></image>
					<view class="right">
						<view class="name">
							{{item.name}}
						</view>
						<view class="author">
							X {{item.num}}
						</view>
						<!-- <view class="code">
							
						</view> -->

					</view>
				</view>
				<view class="goodsinfo">
					<view class="goodsli nextli ">
						<view class="left">
							订单编号
						</view>
						<view class="right">
							{{info.order_id}}
						</view>
					</view>
					<view class="goodsli">
						<view class="left">
							订单金额
						</view>
						<view class="right">
							{{info.amount}}
						</view>
					</view>
					<view class="goodsli">
						<view class="left">
							支付方式
						</view>
						<view class="right">
							{{info.pay_type}}
						</view>
					</view>
					<view class="goodsli nextli">
						<view class="left">
							订单状态
						</view>
						<view class="right">
							{{info.status_1}}
						</view>
					</view>
					<view class="goodsli nextli">
						<view class="left">
							下单时间
						</view>
						<view class="right">
							{{info.add_time}}
						</view>
					</view>
					<view class="goodsli ">
						<view class="left">
							支付时间
						</view>
						<view class="right">
							{{info.pay_time}}
						</view>
					</view>
					<view class="goodsli" v-if="info.express_name != null">
						<view class="left">
							快递名称
						</view>
						<view class="right">
							{{info.express_name}}
						</view>
					</view>
					<view class="goodsli" v-if="info.express_num != null">
						<view class="left">
							快递单号
						</view>
						<view class="right">
							{{info.express_num}}
						</view>
					</view>

				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		OrderSee
	} from '../../api/user.js'
	export default {
		data() {
			return {
				id: '',
				info: []
			}
		},
		onLoad(e) {
			this.id = e.id
			console.log(e)
			this.OrderSee()
		},
		methods: {
			getimg(url) {
				return this.websiteUrl + url
			},
			OrderSee() {
				OrderSee({
					order_id: this.id
				}).then(res => {
					console.log(res)
					this.info = res.data
				})
			},
			toPage(url) {
				uni.redirectTo({
					url: url
				})
			}
		},
		// 过滤时间格式
		// filters: {
		// 	formatData(value) {
		// 		var date = new Date(parseInt(value + '000'));
		// 		var month = date.getMonth() + 1;
		// 		var hours = date.getHours();
		// 		if (hours < 10)
		// 			hours = "0" + hours;
		// 		var minutes = date.getMinutes();
		// 		if (minutes < 10)
		// 			minutes = "0" + minutes;
		// 		var time = date.getFullYear() + "-" + month + "-" + date.getDate() +
		// 			" " + hours + ":" + minutes;
		// 		return time;
		// 	}
		// }
	}
</script>

<style lang="scss">
	.address {

		display: flex;
		align-items: center;
		width: 84%;
		background: #fff;
		padding: 5%;
		margin: 20rpx auto;
		margin-top: 0;
		border-radius: 16rpx;

		image {
			width: 40rpx;
			height: 40rpx;
		}

		.info {
			width: 80%;
			margin-left: 40rpx;
			font-size: 15px;

			.phone {
				font-size: 12px;
				margin-left: 40rpx;
				color: #777;
			}

			.addressmsg {
				margin-top: 20rpx;
			}
		}
	}


	.list {
		.item {
			color: #000;
			width: 98%;
			margin: 0 auto;
			padding-top: 10px;

			.top {
				display: flex;
				align-items: center;
				background: #fff;
				padding: 10px;
				border-radius: 8px;

				image {
					width: 80px;
					height: 80px;
				}

				.right {
					flex: 1;
					padding-left: 20px;

					.name {
						font-size: 16px;
					}

					.author {
						font-size: 14px;
						margin-top: 10px;
						text-align: right;
					}

					.share {
						display: flex;
						font-size: 12px;
						align-items: center;
						color: #a6894d;
						width: 140px;
						border-radius: 5px;
						position: relative;
						margin-top: 8px;

						image {
							width: 20px;
							height: 20px;
							position: absolute;
							left: 0;
						}

						.text {
							background: linear-gradient(90deg, #eccc93, #ebdbb1);
							height: 20px;
							line-height: 20px;
							border-radius: 5px;
							width: 99px;
							padding-left: 20px;
							margin-left: 10px;
						}
					}

					.taps {
						text-align: right;

						text {
							font-size: 14px;
							background: #1DC846;
							color: #000;
							padding: 5px;
							border-radius: 8px;
						}
					}
				}
			}

			.goodsinfo {
				.goodsli {
					display: flex;
					justify-content: space-between;
					padding: 20px 8px;
					font-size: 14px;
					background: #fff;

				}

				.nextli {
					margin-top: 10px;
				}


			}
		}
	}
</style>